﻿#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

char a[1000][1000];
int mypow(int d)
{
    int ans = 1;
    for (int i = 1; i <= d; i++)
        ans *= 3;
    return ans;
}

void dfs(int cur, int x, int y)
{
    if (cur == 1)
    {
        a[x][y] = 'X';
        return;
    }
    int s = mypow(cur - 2);
    dfs(cur - 1, x, y);//打出左上的X应该变为的图形；
    dfs(cur - 1, x, y + 2 * s);//打出右上的X应该变为的图形；
    dfs(cur - 1, x + s, y + s);//打出中间的X应该变为的图形；
    dfs(cur - 1, x + 2 * s, y);//打出左下的X应该变为的图形；
    dfs(cur - 1, x + 2 * s, y + 2 * s);//打出右下的X应该变为的图形；
}

int main()
{
    int n;
    while (scanf("%d", &n)!=EOF)
    {
        if (n == -1)
            break;
        memset(a, ' ', sizeof(a));
        dfs(n, 1, 1);
        int s = mypow(n - 1);
        for (int i = 1; i <= s; i++)//横着的长度为3的n-1次方，纵着的长度为3的n-1次方
        {
            a[i][s + 1] = '\0';//在3的n-1次方后面没有多余的空格
        }
        for (int i = 1; i <= s; i++)
        {
            printf("%s\n", a[i] + 1);
        }
        printf("-\n");
    }
    return 0;
}


/*
Description

A fractal is an object or quantity that displays self-similarity, in a somewhat technical sense, on all scales. The object need not exhibit exactly the same structure at all scales, but the same "type" of structures must appear on all scales.
A box fractal is defined as below :
A box fractal of degree 1 is simply
X
A box fractal of degree 2 is
X X
X
X X
If using B(n - 1) to represent the box fractal of degree n - 1, then a box fractal of degree n is defined recursively as following
B(n - 1)        B(n - 1)

 B(n - 1)

B(n - 1)        B(n - 1)

Your task is to draw a box fractal of degree n.
Input

The input consists of several test cases. Each line of the input contains a positive integer n which is no greater than 7. The last line of input is a negative integer −1 indicating the end of input.
Output

For each test case, output the box fractal using the 'X' notation. Please notice that 'X' is an uppercase letter. Print a line with only a single dash after each test case.
Sample Input

1
2
3
4
-1
Sample Output

X
-
X X
 X
X X
-
X X   X X
 X     X
X X   X X
   X X
    X
   X X
X X   X X
 X     X
X X   X X
-
X X   X X         X X   X X
 X     X           X     X
X X   X X         X X   X X
   X X               X X
    X                 X
   X X               X X
X X   X X         X X   X X
 X     X           X     X
X X   X X         X X   X X
         X X   X X
          X     X
         X X   X X
            X X
             X
            X X
         X X   X X
          X     X
         X X   X X
X X   X X         X X   X X
 X     X           X     X
X X   X X         X X   X X
   X X               X X
    X                 X
   X X               X X
X X   X X         X X   X X
 X     X           X     X
X X   X X         X X   X X
-
*/